<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
		<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
		<link rel="stylesheet" href="../../css/animate.css">
		<link rel="stylesheet" href="../../iconfont/iconfont.css">
		<link rel="stylesheet" href="../../css/mescroll.css">
		<link rel="stylesheet" href="../../css/gloab.css">
		<title>我发布的广告</title>
		<style>
			.none-order {
				text-align: center;
				color: #727272;
				line-height: 200%;
				margin-top: 1rem;
			}

			.product-content {
				width: 100%;
				background: #e4e4e4;
				padding: 0.1rem 0;
			}
		</style>
	</head>
	<body>
		<div id="app">
			<div id="public-header">
				<div id="statusbar"></div>
				<header class="public-header">
					<div class="public-header-lf iconfont icon-fanhui" @click="javascript:api.closeWin();"></div>
					<div class="public-header-title">我发布的广告</div>
				</header>
			</div>
			<div id="mescroll" class="mescroll">
				<div>
					<div class="product-content">
						<div style="width:94%;margin:auto;">
							1、二维码有效期为2个月，过期后不再展示。若置顶，则到置顶结束期为止。<br>
							2、排名优先顺序为：<font style="color:#f00;">置顶>刷新>普通贴</font><br>
							3、发<font style="color:#f00;">涉黄图片</font>或损害其他站长利益的<font style="color:#f00;">同类型广告、</font>加粉、任务平台信息将做<font style="color:#f00;">封号</font>处理，禁止发布多条雷同信息刷屏
						</div>
					</div>
					<div class="product-category-list auto">
						<div class="product-category-list-son" v-if="list.length>0" v-for="(item,index) in list">
							<div class="myfabu-header flex">
								<div class="myfabu-header-lf F4">
									<span class="myfabu-header-pm" style="color:#f00;">排名：{{item.rank}}</span>
									<span>时间：{{item.create_time}}</span>
								</div>
							</div>
							<div class="flex wrap">
								<div class="product-category-list-text" style="width:86%;height:0.8rem;overflow:hidden;" v-html="item.content"></div>
								<div class="jiafen-quanwen" @click="javascript:api.openWin({name: 'guanggao_details',url:'./guanggao_details.html',pageParam: {id: item.id,uid:$api.getStorage('token'),block:item.block}});">全文></div>
							</div>
							<div class="product-category-list-footer clearfix" style="margin-top:0.1rem;">
								<span v-if="item.ids==2" style="width:5%;height:5%;line-height:5%;float:left;"><img src="../../image/public/hb.png"
									 alt=""></span>
								<span style="margin-left:0.05rem;" class="wshy">{{item.block}}</span>
								<span>曝光次数：{{item.view_count}}&nbsp;&nbsp;刷新：{{item.update_time_str}}</span>
							</div>
							<div v-if="item.imgs&&item.imgs.length>0">
								<div class="product-category-list-imgs flex wrap">
									<div class="product-category-list-img" v-if="index<3" :style="index==0?'margin-left:0;':''" v-for="(items,index) in item.imgs"><img
										 @click="seeImg(item,index)" :src="apiUrl1+items" alt=""></div>
									<div class="product-category-list-img" v-if="item.imgs.length>3" @click="seeImg(item,3)">
										<img :src="apiUrl1+item.imgs[3]" alt="">
										<div class="product-category-list-modify">更多图片</div>
									</div>
								</div>
							</div>
							<div class="product-category-list-header-name-lb F5">
								<span class="zd-label" @click="zhiding(item.id)">设置置顶</span>
								<span class="zdsx-label" @click="manualRefreshs(item.id)">自动刷新</span>
								<span class="zdsx-label" @click="manualRefresh(item.id)">手动刷新</span>
								<span class="zdsx-label" @click="del(item.id)">删除</span>
								<span class="zdsx-label" @click="javascript:api.openWin({name: 'fabu',url:'../home/fabu.html',});">发布</span>
								<span class="zdsx-label" @click="modify(item.id,item.block)">修改</span>
							</div>
							<div class="product-category-list-foote" style="color:#999;" v-if="item.startime">
								头条时间:<font style="color:#f00;">{{item.startime}}</font>至<font style="color:#f00;">{{item.endtime}}</font>
							</div>
						</div>
						<!-- <div v-if="list&&list.length<=0" class="none-order">
        <span>暂无数据</span>
      </div> -->
					</div>
				</div>
			</div>
		</div>
		<div class="public-progress" style="z-index:9;">
			<img src="../../icon/icon150x150.png" alt="" class="animated infinite flash" style="width:200px;height:200px;display:block;margin:200px auto;">
		</div>
	</body>
	<script src="../../script/api.js"></script>
	<script src="../../script/jquery.js"></script>
	<script src="../../script/mescroll.js"></script>
	<script src="../../script/vue.js"></script>
	<script src="../../script/app.js"></script>
	<script src="../../script/jsencrypt.js"></script>
	<script src="../../script/fastclick.js"></script>

	<script>
		var vm;
		var mescroll;
		var mySwiper;
		apiready = function() {
			api.removeLaunchView();
			setBar("statusbar");
			setFont(750);
			startVue();
			NewMescroll();
			var top = $("#public-header").outerHeight(true);
			$("#mescroll").css({
				"top": top + "px"
			});
			$(".public-progress").fadeOut(1000);
			setTimeout(function() {
				$(".public-progress").css({
					"display": "none"
				});
			}, 1000);
		}

		function startVue() {
			vm = new Vue({
				el: "#app",
				data: {
					gdtt: ["", "", "", "", "", ""],
					num: 'hidden',
					list: [],
					price: '',
					page: 1,
				},
				mounted: function() {

				},
				methods: {
					//修改广告
					modify: function(index,block) {
						api.openWin({
							name: 'updatead',
							url: './updatead.html',
							pageParam: {
								ids: index,
								block:block
							}
						});

						// api.ajax({
						//     url: apiUrl+'api/users/modify',
						//     method: 'post',
						//     data: {
						//         values: {
						//           ids:post_en(index),
						//         },
						//     }
						// },function(ret, err){
						//     if (ret.status) {
						//       msg(ret.msg);
						//       setTimeout(function(){
						//         vm.myAdList();
						//       },500)
						//     } else {
						//       msg(ret.msg);
						//     }
						// });

					},
					zhiding: function(index) {
						api.ajax({
							url: apiUrl + '/api/index/isTop',
							method: 'post',
							data: {
								values: {
									id: index,
								},
							}
						}, function(ret, err) {
							if (ret.code==1) {
								console.log(JSON.stringify(ret))
								msg(ret.msg);
								return;
							} else {
								api.openWin({
									name: 'zhiding',
									url: './zhiding.html',
									pageParam: {
										id: index
									}
								});
							}
						});
					},
					seeImg: function(data, index) {
						var array = [];
						for (var i = 0; i < data.imgs.length; i++) {
							array.push(apiUrl1 + data.imgs[i]);
						}
						var photoBrowser = api.require('photoBrowser');
						photoBrowser.open({
							images: array,
							placeholderImg: 'widget://res/img/apicloud.png',
							bgColor: '#000'
						}, function(ret, err) {
							if(ret.eventType == 'longPress'){ save_img(array); }
							if (ret.eventType == 'click') {
								var photoBrowser = api.require('photoBrowser');
								photoBrowser.close();
							}
						});
						photoBrowser.setIndex({
							index: index
						});
					},
					more: function(obj) {
						if (obj.num) {
							vm.page++;
						} else {
							vm.page = 1;
							mescroll.lockUpScroll(false);
						}
						vm.myAdList();
					},
					//删除广告
					del: function(index) {
						var id = index;
						var dialogBox = api.require('dialogBox');
						dialogBox.alert({
							texts: {
								content: '确认删除此广告',
								leftBtnTitle: '取消',
								rightBtnTitle: '确认'
							},
							styles: {
								bg: '#fff',
								w: 300,
								corner: 2,
								content: {
									color: '#000',
									size: 14
								},
								left: {
									marginB: 7,
									marginL: 20,
									w: 130,
									h: 35,
									corner: 2,
									bg: '#fff',
									size: 12
								},
								right: {
									marginB: 7,
									marginL: 10,
									w: 130,
									h: 35,
									corner: 2,
									bg: '#fff',
									size: 12
								}
							}
						}, function(ret) {
							if (ret.eventType == 'left') {
								var dialogBox = api.require('dialogBox');
								dialogBox.close({
									dialogName: 'alert'
								});
								location.reload();
							} else if (ret.eventType == 'right') {
								var dialogBox = api.require('dialogBox');
								dialogBox.close({
									dialogName: 'alert'
								});
								api.ajax({
									url: apiUrl + '/api/user/delAd',
									method: 'post',
									data: {
										values: {
											aid: id,
											token: $api.getStorage('token'),
										},
									}
								}, function(ret, err) {
									if (ret.code==1) {
										api.toast({
											msg: '删除成功',
											duration: 2000,
											location: 'middle'
										});
										setTimeout(function() {
											location.reload();
										}, 500);
									} else {
										api.toast({
											msg: ret.msg,
											duration: 2000,
											location: 'middle'
										});
										setTimeout(function() {
											location.reload();
										}, 500);
									}
								});
							}
						});
					},
					//自动刷新
					manualRefreshs: function(index) {
						api.ajax({
							url: apiUrl + '/api/index/isTop',
							method: 'post',
							data: {
								values: {
									id: index
								},
							}
						}, function(ret, err) {
							if (ret.code == 1) {
								api.openWin({
									name: 'refresh',
									url: './refresh.html',
									pageParam: {
										id: index
									}
								});
							} else {
								var dialogBox = api.require('dialogBox');
								dialogBox.alert({
									texts: {
										content: '请先置顶该广告，再自动刷新',
										leftBtnTitle: '取消',
										rightBtnTitle: '去置顶'
									},
									styles: {
										bg: '#fff',
										w: 300,
										corner: 2,
										content: {
											color: '#000',
											size: 14
										},
										left: {
											marginB: 7,
											marginL: 20,
											w: 130,
											h: 35,
											corner: 2,
											bg: '#fff',
											size: 12
										},
										right: {
											marginB: 7,
											marginL: 10,
											w: 130,
											h: 35,
											corner: 2,
											bg: '#fff',
											size: 12
										}
									}
								}, function(ret) {
									if (ret.eventType == 'left') {
										var dialogBox = api.require('dialogBox');
										dialogBox.close({
											dialogName: 'alert'
										});
									} else if (ret.eventType == 'right') {
										var dialogBox = api.require('dialogBox');
										dialogBox.close({
											dialogName: 'alert'
										});
										api.openWin({
											name: 'zhiding',
											url: './zhiding.html',
											pageParam: {
												id: index
											}
										});
									}
								});
							}
						});
					},
					//手动刷新
					manualRefresh: function(index) {
						api.ajax({
							url: apiUrl + '/api/index/isTop',
							method: 'post',
							data: {
								values: {
									id: index
								},
							}
						}, function(ret, err) {
							if (ret.code == 1) {
								var dialogBox = api.require('dialogBox');
								dialogBox.alert({
									texts: {
										content: '手动刷新该广告将支付' + vm.price + '积分是否刷新？',
										leftBtnTitle: '取消',
										rightBtnTitle: '确认'
									},
									styles: {
										bg: '#fff',
										w: 300,
										corner: 2,
										content: {
											color: '#000',
											size: 14
										},
										left: {
											marginB: 7,
											marginL: 20,
											w: 130,
											h: 35,
											corner: 2,
											bg: '#fff',
											size: 12
										},
										right: {
											marginB: 7,
											marginL: 10,
											w: 130,
											h: 35,
											corner: 2,
											bg: '#fff',
											size: 12
										}
									}
								}, function(ret) {
									if (ret.eventType == 'left') {
										var dialogBox = api.require('dialogBox');
										dialogBox.close({
											dialogName: 'alert'
										});
									} else if (ret.eventType == 'right') {
										var dialogBox = api.require('dialogBox');
										dialogBox.close({
											dialogName: 'alert'
										});
										api.ajax({
												url: apiUrl + '/api/user/handRefresh',
												method: 'post',
												data: {
													values: {
														token: $api.getStorage('token'),
														aid: index,
													},
												},
											},
											function(ret, err) {
												console.log(JSON.stringify(ret))
												if (ret.code == 1) {
														api.toast({
															msg: ret.msg,
															duration: 2000,
															location: 'middle'
														});
												}else{
													api.toast({
													    msg: ret.msg,
													    duration: 2000,
													    location: 'middle'
													});
													setTimeout(function(){
													  location.reload();
													  api.openWin({
													      name: 'buy_jifen',
													      reload:true,
													      url: './buy_jifen.html',
													  });
													},500);
												}
											});
									} else {
										var dialogBox = api.require('dialogBox');
										dialogBox.alert({
											texts: {
												content: '请先置顶该广告，再手动刷新',
												leftBtnTitle: '取消',
												rightBtnTitle: '去置顶'
											},
											styles: {
												bg: '#fff',
												w: 300,
												corner: 2,
												content: {
													color: '#000',
													size: 14
												},
												left: {
													marginB: 7,
													marginL: 20,
													w: 130,
													h: 35,
													corner: 2,
													bg: '#fff',
													size: 12
												},
												right: {
													marginB: 7,
													marginL: 10,
													w: 130,
													h: 35,
													corner: 2,
													bg: '#fff',
													size: 12
												}
											}
										}, function(ret) {
											if (ret.eventType == 'left') {
												var dialogBox = api.require('dialogBox');
												dialogBox.close({
													dialogName: 'alert'
												});
											} else if (ret.eventType == 'right') {
												var dialogBox = api.require('dialogBox');
												dialogBox.close({
													dialogName: 'alert'
												});
												api.openWin({
													name: 'zhiding',
													url: './zhiding.html',
													pageParam: {
														id: vm.list[index].id
													}
												});
											}
										});
									}
								});
							}
						});
					},
					change: function(index) {
						if (vm.num == index) {
							vm.num = 'hidden';
						} else {
							vm.num = index;
						}
					},
					myAdList: function() {
						api.showProgress({
							title: '努力加载中...',
							text: '先喝杯茶...',
							modal: false
						});
						api.ajax({
							url: apiUrl + '/api/user/ads',
							method: 'post',
							data: {
								values: {
									token: $api.getStorage('token'),
									page: vm.page
								},
							}
						}, function(ret, err) {
							if (vm.page == 1) {
								vm.list = [];
							}
							if (ret.code == 1) {
								if (vm.list.length >= ret.data.total && vm.list.length != 0) {
									msg("我也是有底线的！");
									mescroll.lockUpScroll(true);
									api.hideProgress();
								} else {
									api.hideProgress();
									for (var i = 0; i < ret.data.list.length; i++) {
										vm.list.push(ret.data.list[i]);
									}
								}
								// vm.list = ret.data;
								/* vm.price = ret.price; */
							} else {
								api.hideProgress();
								mescroll.lockUpScroll(true);
								msg("没有过多数据！");
							}
							mescroll.endUpScroll(false);
							mescroll.endSuccess();
						});
					},
				}
			})
		}

		function NewMescroll() {
			mescroll = new MeScroll("mescroll", {
				down: {
					use: true,
					auto: true,
					// autoShowLoading:true,
					callback: vm.more, //下拉刷新的回调,别写成downCallback(),多了括号就自动执行方法了
				},
				up: {
					use: true,
					auto: false,
					lazyLoad: {
						use: true, // 是否开启懒加载,默认false
						attr: 'imgurl', // 网络地址的属性名 (图片加载成功会移除该属性): <img imgurl='网络图  src='占位图''/>
						showClass: 'mescroll-lazy-in', // 图片加载成功的显示动画: 渐变显示,参见mescroll.css
						delay: 500, // 列表滚动的过程中每500ms检查一次图片是否在可视区域,如果在可视区域则加载图片
						offset: 200 // 超出可视区域200px的图片仍可触发懒加载,目的是提前加载部分图片
					},
					callback: vm.more, //上拉刷新的回调,别写成downCallback(),多了括号就自动执行方法了
				}
			})
		}
	</script>
</html>
